import java.util.Scanner;

public class HJ55 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            String str;
            int count = 0;
            //i = 0开始0也会算，就多了一个
            for(int i = 1; i <= n; i++){
                str = String.valueOf(i);
                if(str.contains("7") || i % 7 == 0){
                    count++;
                }
            }

            System.out.println(count);
        }
        sc.close();
    }
}
